package com.rd.project.controller;

import com.rd.project.model.Klas;
import com.rd.project.model.Score;
import com.rd.project.model.Student;
import com.rd.project.model.Test;
import com.rd.project.model.Vak;
import com.rd.project.service.PuntenService;
import java.util.List;
import java.util.Map;
import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.context.FacesContext;

/**
 *
 * @author Stefan
 */
@ManagedBean(name = "puntenController")
public class PuntenController {

    private List<Score> scores;
    private Student student;
  

    @EJB
    private PuntenService puntenService;

    @PostConstruct
    public void init() {
        scores = this.getScores();
        Map<String, String> params;
        params = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
        String id = params.get("id");
        student = puntenService.getStudent(Integer.parseInt(id));
    }

  

    public List<Score> getScores() {
        return puntenService.getAlleScore();
    }


    public List<Score> getScoreFromStudentId(int id) {
        return puntenService.getScoreFromStudentId(id);
    }

    public List<Score> getScoreFromTestId(int id) {
        return puntenService.getScoreFromTestId(id);
    }

    public int getTestIdFromScoreId(int id) {
        return puntenService.getTestIdFromScoreId(id);
    }

    public Test getTestFromTestId(int id) {
        return puntenService.getTestFromTestId(id);
    }

    public Test getTestFromScoreId(int scoreId) {
        return puntenService.getTestFromScoreId(scoreId);
    }
    public Student getStudent(){
        return this.student;
    }
    public void setStudent(Student student){
        this.student = student;
    }      
    
    public Vak getVak(int vakId) {
        return puntenService.getVak(vakId);
    }
    
    public Klas getKlasFromStudent() {
        return puntenService.getKlasFromStudentId(this.student.getId().intValue());
    }
}
